Imports cmplib01

Public Class frmChitTreeHierarchy
    Inherits System.Windows.Forms.Form

    Private ptrSelectedChit As ChitUnitTypeMember


#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents btnOK As System.Windows.Forms.Button
    Friend WithEvents pnlTopBorder As System.Windows.Forms.Panel
    Friend WithEvents txtTitleBox As System.Windows.Forms.TextBox
    Friend WithEvents pnlChitElementList As System.Windows.Forms.Panel
    Friend WithEvents tvwElementList As System.Windows.Forms.TreeView
    Friend WithEvents ImageList1 As System.Windows.Forms.ImageList
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Me.btnOK = New System.Windows.Forms.Button
        Me.pnlTopBorder = New System.Windows.Forms.Panel
        Me.txtTitleBox = New System.Windows.Forms.TextBox
        Me.pnlChitElementList = New System.Windows.Forms.Panel
        Me.tvwElementList = New System.Windows.Forms.TreeView
        Me.ImageList1 = New System.Windows.Forms.ImageList(Me.components)
        Me.pnlTopBorder.SuspendLayout()
        Me.pnlChitElementList.SuspendLayout()
        Me.SuspendLayout()
        '
        'btnOK
        '
        Me.btnOK.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.btnOK.BackColor = System.Drawing.Color.LightSkyBlue
        Me.btnOK.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.btnOK.Location = New System.Drawing.Point(187, 376)
        Me.btnOK.Name = "btnOK"
        Me.btnOK.Size = New System.Drawing.Size(75, 23)
        Me.btnOK.TabIndex = 20
        Me.btnOK.Text = "OK"
        Me.btnOK.UseVisualStyleBackColor = False
        '
        'pnlTopBorder
        '
        Me.pnlTopBorder.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.pnlTopBorder.BackColor = System.Drawing.Color.SteelBlue
        Me.pnlTopBorder.Controls.Add(Me.txtTitleBox)
        Me.pnlTopBorder.Location = New System.Drawing.Point(0, 8)
        Me.pnlTopBorder.Name = "pnlTopBorder"
        Me.pnlTopBorder.Size = New System.Drawing.Size(288, 40)
        Me.pnlTopBorder.TabIndex = 19
        '
        'txtTitleBox
        '
        Me.txtTitleBox.BackColor = System.Drawing.Color.SteelBlue
        Me.txtTitleBox.BorderStyle = System.Windows.Forms.BorderStyle.None
        Me.txtTitleBox.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.txtTitleBox.ForeColor = System.Drawing.Color.WhiteSmoke
        Me.txtTitleBox.Location = New System.Drawing.Point(32, 8)
        Me.txtTitleBox.Multiline = True
        Me.txtTitleBox.Name = "txtTitleBox"
        Me.txtTitleBox.ReadOnly = True
        Me.txtTitleBox.Size = New System.Drawing.Size(240, 26)
        Me.txtTitleBox.TabIndex = 8
        Me.txtTitleBox.TabStop = False
        Me.txtTitleBox.Text = "Chit Elements"
        '
        'pnlChitElementList
        '
        Me.pnlChitElementList.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                    Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.pnlChitElementList.BackColor = System.Drawing.Color.LightSkyBlue
        Me.pnlChitElementList.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.pnlChitElementList.Controls.Add(Me.tvwElementList)
        Me.pnlChitElementList.Location = New System.Drawing.Point(8, 56)
        Me.pnlChitElementList.Name = "pnlChitElementList"
        Me.pnlChitElementList.Size = New System.Drawing.Size(267, 312)
        Me.pnlChitElementList.TabIndex = 18
        '
        'tvwElementList
        '
        Me.tvwElementList.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                    Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.tvwElementList.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.tvwElementList.Location = New System.Drawing.Point(8, 8)
        Me.tvwElementList.Name = "tvwElementList"
        Me.tvwElementList.Size = New System.Drawing.Size(251, 296)
        Me.tvwElementList.TabIndex = 0
        '
        'ImageList1
        '
        Me.ImageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit
        Me.ImageList1.ImageSize = New System.Drawing.Size(16, 16)
        Me.ImageList1.TransparentColor = System.Drawing.Color.Transparent
        '
        'frmChitTreeHierarchy
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.BackColor = System.Drawing.Color.Black
        Me.ClientSize = New System.Drawing.Size(282, 408)
        Me.Controls.Add(Me.btnOK)
        Me.Controls.Add(Me.pnlTopBorder)
        Me.Controls.Add(Me.pnlChitElementList)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow
        Me.Name = "frmChitTreeHierarchy"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.pnlTopBorder.ResumeLayout(False)
        Me.pnlTopBorder.PerformLayout()
        Me.pnlChitElementList.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region


    Public Shadows Sub ShowDialog(ByRef Chit As ChitUnitTypeMember)
        ptrSelectedChit = Chit
        BuildTree()

        MyBase.ShowDialog()

    End Sub

    Private Sub BuildTree()

        Try
            'tvwElementList.Nodes.Clear()

            ''// first list the chit name
            'Dim nod As New TreeNode(ptrSelectedChit.Name)
            'tvwElementList.Nodes.Add(nod)

            ''// and add the group sub nodes
            'Dim group As ElementGroup
            'Dim EleGroup As GroupableElements = ptrSelectedChit.elements
            'Dim notGrouped As New TreeNode("Ungrouped")

            'For Each group In EleGroup.Groups
            '    Dim GroupNode As New TreeNode(group.GroupName)
            '    nod.Nodes.Add(GroupNode)
            'Next

            'Dim ele As GroupableElement

            ''// first post the Non-grouped elements
            'For Each ele In EleGroup
            '    If ele.GroupName = "<Ungrouped>" Then
            '        notGrouped.Nodes.Add("(" & ele.Count & ") " & ele.ElementTypeName)
            '    End If
            'Next

            'nod.Nodes.Add(notGrouped)

            ''// now go through all of the elements and find the group it belongs to
            'For Each ele In EleGroup
            '    Dim nodie As TreeNode
            '    For Each nodie In nod.Nodes
            '        If ele.GroupName = nodie.Text Then
            '            Dim eleNode As New TreeNode("(" & ele.Count & ") " & ele.ElementTypeName)
            '            nodie.Nodes.Add(eleNode)
            '            eleNode.EnsureVisible()
            '        End If
            '    Next
            'Next
        Catch ex As Exception
            HandleException("frmChitTreeHierarchy.BuildTree", ex)
        End Try

    End Sub

    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
        Me.Hide()
    End Sub
End Class
